<template>
	<view>
		<view class="flex-row center-row container-bg">
			<!-- canvas模块 -->
			<view class="flex-column container-bg-left" style="width: 84rpx; height: 100%;">
				<icon-index :number="Number(data.chance_lv)" :index="String(data.chance)" baifenhao="%"
					fontsSize='28rpx'></icon-index>
				<text class="left-hint" :style="{'color':chanceColor}">{{chanceLab}}</text>
				<text style="height: 60rpx; font-size: 20rpx;color: #999;">{{data.probabilityExplain}}</text>
				<text style="width: 84rpx;"></text>
			</view>


			<!-- 中间模块 修改块 报错模块-->
			<view class="flex-column container-right" style="width: 480rpx;">
				<view class="flex-row text-right-bold">
					<view class="flex-column">
						<text @tap.stop="triggerGetMoreYearInfo" style="margin-bottom: 10rpx;font-size: 36rpx;"
							:class="data.isFit==0?'changeColor':''">{{data.collegeRealName}}</text>
						<text class="text-999 collegeRemark"
							style="color: #333; padding-right: 10rpx;">{{ data.collegeRemark }}</text>
					</view>
				</view>

				<view class="flex-column text-999">
					<text class="text-999 label">{{ data.features.join(' / ') }}</text>

					<view class="province-city">
						<view class="province">
							<image class="address"
								src="https://mcdn.chatgk.com/xcx/static/images/zhinengtianbao/address.png" mode="">
							</image>
							<text>
								{{ data.provinceName + ' ' + data.cityName + ' ' + data.categories.join(' / ') + ' / ' + data.natureType + ' / '+ '排名'+(data.rank <= 0 ? '-':data.rank) }}</text>
						</view>
					</view>
					<view class="plan" style="width: 120%;">
						<text>
							{{data.planYear + '年计划:'}}
							<text class="text-464646" :class="data.isFit==0?'changeColor':''">
								{{ data.planNum + '人'}}
							</text>
						</text>

						<text>
							代码:
							<text class="text-464646">
								{{ data.collegeEnrollCode }}
							</text>
						</text>

						<text>
							<text class="text-464646">
								{{ data.chooseSubjectText }}
							</text>
						</text>
					</view>
				</view>
				<view :class="data.isFit==0?'changeColor':''" class="fromBox" v-if="isShowMoreYearList(data.moreYear)">
					<view class="flex-row fromBox-head">
						<view style="width: 15%; text-align: center;" align="center">年份</view>
						<view style="width: 15%; text-align: center;" align="center">科类</view>
						<view style="width: 15%; text-align: center;" align="center">录取</view>
						<view style="width: 16%; text-align: center;" align="center">最低分</view>
						<view style="width: 22%; text-align: center;" align="center">最低位次</view>
						<view style="width: 26%; text-align: center;" align="center">
							<view class="th-item flex-row center-row align-center" @tap.stop="popupMessage">
								<view>等效位差</view>
								<image src="https://mcdn.chatgk.com/xcx/static/images/zhinengtianbao/wenhao.png" mode=""
									style="width: 18rpx; height: 18rpx;"></image>
							</view>
						</view>
					</view>
					<view class="flex-row flex-row-table" v-for="(ele, index) in data.moreYear" :key="index">
						<view style="width: 15%; text-align: center;" align="center">
							{{ ele.year || ' - ' }}
						</view>
						<view style="width: 15%; text-align: center;" align="center">
							{{ele.course || ' - '}}

						</view>
						<view style="width: 15%; text-align: center;" align="center">
							{{ ele.enterNum || ' - '}}
						</view>
						<view style="width: 16%; text-align: center; position: relative;" align="center">
							{{ ele.minScore }}
							<text v-if="ele.zjText&&ele.zjText.length>0&&ele.minScore*1>0"
								@tap="onzhengshowboxopen(ele.year)" class="" style="color: red;">
								征
							</text>
						</view>
						<view style="width: 22%; text-align: center;" align="center">
							{{ ele.minRank || '-'}}
						</view>
						<view style="width: 26%; text-align: center;" align="center">
							<span v-if="ele.equivalentBitDifference == '-' || !ele.equivalentBitDifference"> - </span>
							<span v-else-if=" ele.equivalentBitDifference < 0" style="color: #FF7E36;;">
								低{{ ele.equivalentBitDifference.toString().substring(1) }}</span>
							<span v-else-if="ele.equivalentBitDifference >= 0" style="color: #20ED33;">
								高{{ ele.equivalentBitDifference }}</span>
						</view>

					</view>
				</view>

			</view>
			<!-- 按钮模块 -->
			<view v-show="isShowMajors&&data.isFit==1" class="button-major" :class="isFilled ? 'select':''"
				@tap.stop="onClickCollegeMajors">{{'专业' + data.majorsInfo.length}}
				<!-- 这是四川 -->
				<view v-if="area==3" class="button-major-select">
					{{isFilled?'已选'+changeSelectText():''}}
				</view>
				<view v-else class="button-major-select">
					{{isFilled?'已填'+SelectOneText():''}}
				</view>
			</view>
			<view v-show="data.isFit==0" class="button-major2" :class="data.isFit==0?'changeColor':''">
				选科不符
			</view>

		</view>
		<zheng-show v-if="zhengshowbox" :yearText="yearText" @onzhengshowbox="onzhengshowbox"
			style="width: 100vw;height: 100vh;position: fixed;top: 0;z-index: 99999;"></zheng-show>

		<view class="popup-center" v-show="opens" @touchmove.stop.prevent="stopscroll">
			<view class="popup-center-box">
				<view class="p-c-b-top">
					<view class="top-title">
						什么是等效位差？
					</view>
					<text>
						历年等效位差根据考生历年的等效位-历年位次的差值得出，
						换算后的等效位差可更精准的与历年位次进行比较。
					</text>
				</view>
				<view class="p-c-b-bottom">
					<view class="bottom-line">
					</view>
					<image style="width: 60rpx;height: 40%;"
						src="https://mcdn.chatgk.com/xcx/static/images/midTabBar/chacha@3x.png" mode=""
						@tap.stop="endPopup"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import userManager from '@/common/manager/user-manager.js';
	export default {
		props: {
			data: {
				type: Object,
				default: () => {}
			},
			index: {
				type: Number,
				default: 0
			},
			isFilled: {
				type: Boolean,
				default: false
			},
			isShowMajors: {
				type: Boolean,
				default: true
			},
			area: {
				type: Number,
				default: 0
			},
			schoolmajor: {
				type: Array,
				default: () => []
			}
		},
		emits: ["getMoreYearInfo"],
		data() {
			return {
				chanceLab: "--",
				chanceColor: "#FF3B0A",
				state: false,
				selectZY: '', //选择的志愿表的文字  用以下方渲染
				chanceTit: '--',
				yearText: '2023',
				zhengshowbox: false,
				opens: false,
			}
		},


		watch: {
			data: {
				handler(newVal) {
					this.state = this.isFilled
					// this.changeSelectText()
					const lv = this.data.chance_lv
					if (lv == 1) {
						this.chanceLab = '冲'
						this.chanceTit = '风险极大'
						this.chanceColor = '#FF3B0A'
					} else if (lv == 2) {
						this.chanceLab = '稳'
						this.chanceTit = '风险中等'
						this.chanceColor = '#FFD43A'
					} else if (lv == 3) {
						this.chanceLab = '保'
						this.chanceTit = '风险极小'
						this.chanceColor = '#27EC61'
					}
				},
				deep: true,
				immediate: true
			},

		},
		methods: {
			popupMessage() {
				this.opens = true
			},
			endPopup() {
				this.opens = false
			},
			stopscroll() {
				console.log("禁止滚动");
			},
			onzhengshowboxopen(year) {
				this.yearText = year
				this.zhengshowbox = true
			},
			onzhengshowbox() {
				this.zhengshowbox = false
			},

			//四川地区用的变量函数
			changeSelectText() {
				let text = ''
				let info = this.$store.state.user.volunteerInfo || []
				info.forEach(item => {
					if (item.id == this.data.id) {
						text = item.vkey
					}
				})
				return text
			},
			//重庆类别2选择函数
			SelectOneText() {
				let text = 0
				let info = this.$store.state.user.volunteerInfo
				info.forEach(item => {
					if (item.id == this.data.id) {
						text = text + item.majorsInfo.length
					}
				})
				return text
			},
			// 使用递归函数来查找值
			searchNestedObject(obj, targetObj) {
				for (let key in obj) {
					if (typeof obj[key] === 'object') {
						// 如果当前属性值是对象，则递归调用
						if (this.searchNestedObject(obj[key], targetObj)) {
							return true;
						}
					} else if (JSON.stringify(obj[key]) === JSON.stringify(targetObj)) {
						// 如果当前属性值等于目标对象，则返回 true
						return true;
					}
				}
				return false;
			},
			onClickCollegeMajors() {
				this.$emit('onClickCollegeMajor', this.data)
			},

			triggerGetMoreYearInfo() {
				this.$emit('getMoreYearInfo', this.data)
			},

			isShowMoreYearList(listArr) {
				let bool = false

				for (let item of listArr) {
					if (item.minScore > 0 && item.minRank > 0) {
						bool = true
					}
				}

				return bool
			}

		},
		computed: {
			getCollegeTag() {
				let data = this.data
				let tagStr = ""
				if (data.f985 == "1") {
					tagStr += "985 | "
				}
				if (data.f211 == "1") {
					tagStr += "211 | "
				}
				if (data.baoyan == "1") {
					tagStr += "保研 | "
				}
				if (data.dual_class == "1") {
					tagStr += "双一流 | "
				}
				if (data.doublehigh == "1") {
					tagStr += "双高计划 | "
				}
				if (data.central == "1") {
					tagStr += "中央部委 | "
				}
				if (data.department == "1") {
					tagStr += "教育部直属 | "
				}
				if (data.basic == "1") {
					tagStr += "强基计划 | "
				}

				let index = tagStr.lastIndexOf(" | ")
				if (index > 0) {
					tagStr = tagStr.substring(0, index)
				}
				return tagStr
			}
		}
	}
</script>

<style lang="scss" scoped>
	.flex-row {
		display: flex;
		flex-direction: row;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
	}

	.align-center {
		align-items: center;
	}

	.space-between {
		display: flex;
		justify-content: space-between;
	}

	.popup-center {
		width: 100vw;
		height: 100vh;
		background-color: rgba(0, 0, 0, 0.6);
		position: fixed;
		top: 0;
		z-index: 999;
		// display: flex;
		// justify-content: center;
		// align-items: center;
		// overflow: hidden;

		.popup-center-box {
			width: 80%;
			height: 500rpx;
			position: absolute;
			top: 35%;
			left: 10%;

			.p-c-b-top {
				width: 100%;
				height: 50%;
				background-color: #fff;
				padding: 40rpx;
				font-size: 26rpx;
				line-height: 40rpx;
				box-sizing: border-box;
				border-radius: 20rpx;

				.top-title {
					width: 100%;
					display: flex;
					justify-content: center;
					font-size: 38rpx;
					font-weight: 500;
					margin-bottom: 20rpx;
				}
			}

			.p-c-b-bottom {
				width: 100%;
				height: 30%;
				display: flex;
				flex-direction: column;
				align-items: center;

				.bottom-line {
					width: 2rpx;
					height: 40%;

					background-color: #fff;
				}
			}
		}
	}

	button::after {
		border: none;
	}

	.label {
		width: 85%;
		font-size: 20rpx !important;
	}

	.province-city {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: flex-start;
		font-size: 20rpx;
		width: 90%;
		color: #999999;

		.province {
			// line-height: 34rpx;
			margin: 0 6rpx 0 0;
			display: flex;
			flex-direction: row;
			align-items: center;

			.address {
				width: 14rpx;
				height: 20rpx;
				margin-right: 8rpx;
			}
		}
	}

	.plan {
		display: flex;
		justify-content: start;
		align-items: center;
		font-size: 22rpx;
		// line-height: 32rpx;
		color: #999999;
		margin: 8rpx 0 0 0;

		text {
			display: inline-block;
		}

		.text-464646 {
			color: #464646;
			font-weight: bold;
			margin-right: 10rpx;
			font-size: 24rpx;
		}
	}

	.container-bg {
		background: #FFFFFF;
		margin: 24rpx 32rpx 0 32rpx;
		padding: 24rpx 0 26rpx 20rpx;
		border-radius: 20rpx;
		width: calc(100% - 88rpx);
		position: relative;
		display: flex;
		flex-direction: row;
	}

	.container-bg-left {
		display: flex;
		flex-direction: column;
		align-items: center;
		text-align: center;
		margin-top: 60rpx;
		margin-left: 10rpx;
	}

	.container-right {
		/* width: 100%; */
		margin: 0 100rpx 0 20rpx;
	}

	.left-hint {
		// position: absolute;
		// top: 75rpx;
		// left: 40rpx;
		width: 56rpx;
		height: 60rpx;
		margin-top: 6rpx;
		text-align: center;
		font-weight: bold;
	}

	.text-left {
		color: #FF3B0A;
		font-size: 28rpx;
		font-weight: bold;
	}

	.text-right-bold {
		width: 80%;
		color: #464646;
		font-size: 28rpx;
		font-weight: bold;

		.flex-column {
			display: flex;
			flex-direction: column;
		}

		.collegeRemark {
			font-weight: normal;
		}
	}

	.text-999 {
		color: #999;
		font-size: 24rpx;
		margin-bottom: 10rpx;
	}

	.text-464646 {
		color: #464646;
		font-size: 24rpx;
		margin-bottom: 10rpx;
	}

	.text-22 {
		color: #999;
		font-size: 22rpx;
	}

	.button-major {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		height: 48rpx;
		width: 116rpx;
		// line-height: 48rpx;
		text-align: center;
		color: #FF3B0A;
		border: 2rpx solid #FF3B0A;
		border-radius: 24rpx;
		font-size: 22rpx;
		background-color: transparent;
		margin-bottom: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.button-major2 {
		position: absolute;
		top: 30rpx;
		right: 30rpx;
		height: 48rpx;
		width: 90rpx;
		// line-height: 48rpx;
		text-align: center;
		color: #FF3B0A;
		font-size: 22rpx;
		background-color: transparent;
		margin-bottom: 10rpx;

	}

	.button-major-select {
		position: absolute;
		top: 50rpx;
		height: 48rpx;
		width: 90rpx;
		// line-height: 48rpx;
		color: #7a7d82;
		font-size: 22rpx;
		background-color: white;
		margin-bottom: 10rpx;
	}

	.select {
		color: #fff;
		background: #FF3B0A;
		border: none;
	}

	.zwptext {
		font-size: 24rpx;

	}

	.fromBox {
		width: 110%;
		font-size: 12rpx;
		color: #666666;

		// display: flex;
		// flex-direction: row;
		.fromBox-head {
			color: #999999;
			margin: -8rpx 0 0 0;
			display: flex;
			flex-direction: row;
			font-size: 22rpx;
		}

		.from-table {
			width: 100% !important;
			overflow: hidden;
		}

		.flex-row-table {
			margin-top: 10rpx;
			font-size: 20rpx;
			display: flex;
			flex-direction: row;
		}

		.center-row {
			align-items: center;
		}
	}

	.canvas-box {
		position: absolute;
		top: 40rpx;
	}

	.changeColor {
		color: #999999 !important;
	}

	.title2Border {
		color: #464646;
		font-size: 24rpx;
		margin: 4rpx 5rpx 4rpx 0;
		border: 1rpx solid #bbbbbb;
		padding: 0 8rpx;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	@media screen and(min-width:580px) and(max-width: 1024px) {
		.button-major-select {
			left: 0;
		}
	}
</style>